export const ciConfig = {
  // Jenkins配置
  jenkins: {
    server: {
      url: 'http://jenkins.local:8080',
      user: process.env.JENKINS_USER,
      token: process.env.JENKINS_TOKEN,
    },
    // 流水线配置
    pipeline: {
      name: 'livechat-pipeline',
      stages: {
        build: {
          script: 'D:\\jenkins\\scripts\\build.bat',
          timeout: 1800,
        },
        test: {
          script: 'D:\\jenkins\\scripts\\test.bat',
          coverage: true,
        },
        deploy: {
          script: 'D:\\jenkins\\scripts\\deploy.bat',
          environments: ['test', 'staging', 'prod'],
        },
      },
    },
  },

  // 制品管理
  artifacts: {
    // 私有npm仓库
    npm: {
      registry: 'https://registry.npmmirror.com', // 淘宝镜像
      scope: '@livechat',
      publish: {
        registry: 'http://nexus.local:8081/repository/npm-hosted/',
      },
    },
    // Docker镜像仓库
    docker: {
      registry: 'registry.cn-hangzhou.aliyuncs.com', // 阿里云镜像仓库
      namespace: 'livechat',
      credentials: {
        username: process.env.DOCKER_USER,
        password: process.env.DOCKER_PASSWORD,
      },
    },
  },

  // 自动化测试
  testing: {
    // 单元测试
    unit: {
      runner: 'jest',
      coverage: {
        provider: 'istanbul',
        threshold: {
          statements: 80,
          branches: 70,
          functions: 80,
          lines: 80,
        },
      },
    },
    // 接口测试
    api: {
      runner: 'newman', // Postman集合运行器
      collection: 'D:\\tests\\postman\\livechat.json',
      environment: {
        test: 'D:\\tests\\postman\\test-env.json',
        staging: 'D:\\tests\\postman\\staging-env.json',
      },
    },
    // UI自动化测试
    ui: {
      framework: 'cypress',
      browser: ['chrome', 'edge'],
      baseUrl: 'http://localhost:3000',
      video: true,
      screenshots: true,
    },
  },

  // 代码质量
  quality: {
    // Sonar分析
    sonar: {
      server: 'http://sonar.local:9000',
      token: process.env.SONAR_TOKEN,
      projectKey: 'livechat',
      sources: 'src',
      exclusions: '**/*.test.ts,**/*.spec.ts',
    },
    // 代码审查
    review: {
      platform: 'gitee', // 使用码云
      required: true,
      minReviewers: 2,
      assignees: ['tech-lead', 'senior-dev'],
    },
  },

  // 环境配置
  environments: {
    // 测试环境
    test: {
      server: 'test-server.local',
      deploy: {
        path: 'D:\\livechat\\test',
        backup: true,
        rollback: true,
      },
      database: {
        host: 'test-db.local',
        backup: {
          enabled: true,
          path: 'D:\\backups\\test',
        },
      },
    },
    // 预发环境
    staging: {
      server: 'staging-server.local',
      deploy: {
        path: 'D:\\livechat\\staging',
        backup: true,
        rollback: true,
      },
      database: {
        host: 'staging-db.local',
        backup: {
          enabled: true,
          path: 'D:\\backups\\staging',
        },
      },
    },
  },

  // 通知配置
  notification: {
    // 钉钉通知
    dingtalk: {
      enabled: true,
      webhook: process.env.DINGTALK_CI_WEBHOOK,
      events: ['build', 'test', 'deploy', 'review'],
    },
    // 企业微信通知
    wecom: {
      enabled: true,
      webhook: process.env.WECOM_CI_WEBHOOK,
      events: ['build', 'test', 'deploy', 'review'],
    },
    // 邮件通知
    email: {
      enabled: true,
      smtp: {
        host: 'smtp.qq.com',
        port: 465,
        secure: true,
      },
      receivers: ['team@example.com'],
    },
  },
}
